package com.icesoft.xsnow.codegen.engine;

import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.generator.config.builder.ConfigBuilder;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine;
import com.icesoft.xsnow.codegen.api.bo.TablePlus;

import java.util.Map;

/**
 * @program: xsnow
 * @description: VolicityEngine增强-增强参数
 * @author: xuefeng.gao
 * @create: 2019-05-21 14:13
 **/
public class VelocityPlusTemplateEngine extends VelocityTemplateEngine {

    /**
     * 渲染对象 MAP 信息
     *
     * @param tableInfo 表信息对象
     * @return ignore
     */
    @Override
    public Map<String, Object> getObjectMap(TableInfo tableInfo) {
         Map<String, Object> objectMap = super.getObjectMap(tableInfo);

        TablePlus tablePlus = TablePlus.build(tableInfo);
        objectMap.put("tablePlus", tablePlus);
        ConfigBuilder configBuilder = MapUtil.get(objectMap,"config", ConfigBuilder.class);
        objectMap.put("superEntityClassPackage",configBuilder.getSuperEntityClass());
        return objectMap;
    }
}
